//
//  M_HelpDetail.swift
//  letuofu
//
//  Created by WH-JS on 2020/3/26.
//  Copyright © 2020 WH-JS. All rights reserved.
//

import UIKit
import WebKit

class M_HelpDetail: BaseViewControllerWithHeader {
    var detailDic = [String:Any?]()
    let contentWeb = WKWebView()
    var titleLabel = UILabel()

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        setupUI()
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destination.
        // Pass the selected object to the new view controller.
    }
    */

    func setupUI() {
        safeView.backgroundColor = .xF2F2F2
        headView.backgroundColor = .white
        headTitle.text = "帮助"
        
        let titleBg = safeView.drawView { (make) in
            make.top.equalTo(headView.snp.bottom).offset(10)
            make.left.equalToSuperview()
            make.right.equalToSuperview()
            make.height.equalTo(53)
        }
        titleBg.backgroundColor = .white
        
        //画横线
        let line = titleBg.drawView { (make) in
            make.left.equalToSuperview().offset(10)
            make.right.equalToSuperview().offset(-10)
            make.bottom.equalToSuperview()
            make.height.equalTo(1)
        }
        line.backgroundColor = .xF2F2F2
        
        let titlestr = detailDic.getString("title")
        let introduce = titleBg.drawLabel(text: titlestr, fontSize: 14, textColor: .x666666) { (make) in
            make.centerY.equalToSuperview()
            make.left.equalToSuperview().offset(10)
            make.right.equalToSuperview().offset(-10)
        }
        introduce.numberOfLines = 0
        
        safeView.drawView(view: contentWeb) { (make) in
            make.top.equalTo(titleBg.snp.bottom)
            make.left.right.bottom.equalToSuperview()
        }
        let html = "<html><head><style>body{ font-size:35px;} </style><body>" + (detailDic.getString("content") ?? "") + "</body></head></html>"
        contentWeb.loadHTMLString(html, baseURL: nil)
    }
}
